/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package algoritmo;

import java.util.Comparator;
import java.util.PriorityQueue;

public class AStar extends UniformCostSearch {

    private Heuristic heur;

    @Override
    public Comparator getComparator() {
        return new Comparator<Node>() {

            @Override
            public int compare(Node o1, Node o2) {
                
                Integer f1 = o1.getPathCost() + h(o1);
                Integer f2 = o2.getPathCost() + h(o2);
                return f1.compareTo(f2);
            }
        };
    }

    public AStar(Heuristic heur) {
        this.heur = heur;
    }

    protected int h(Node n) {
        return heur.h(n);
    }

    public Heuristic getHeur() {
        return heur;
    }

    public void setHeur(Heuristic heur) {
        this.heur = heur;
    }
}
